package com.wodan.zhongjinjicang.service;

import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @ClassName: ServiceTemplate
 * @Description: 业务处理模板
 * @author chenw
 * @date 2015-2-2 下午2:57:12
 * @history
 */
public interface ServiceTemplate {

	/**
	 * 执行json处理
	 * 
	 * @Description:
	 * @param serviceName
	 *            处理业务的service名称
	 * @param request
	 * @param response
	 * @param handler
	 * @return
	 */
	public String executeJson(String serviceName, HttpServletRequest request, HttpServletResponse response,
							  String sessionId, String message, CallbackHandler handler);

	/**
	 * 返回JSON对象
	 * 
	 * @Description:
	 * @param serviceName
	 *            处理业务的service名称
	 * @param request
	 * @param response
	 * @param handler
	 * @return
	 */
	public JSONObject executeJsonObject(String serviceName, HttpServletRequest request, HttpServletResponse response,
										String sessionId, String message, CallbackHandler handler);
	
	/**
	 * 回调函数
	 * 
	 * @ClassName: CallbackHandler
	 * @author Administrator
	 * @date 2015-1-13 上午11:08:08
	 * @history
	 */
	public static interface CallbackHandler {

		/**
		 * @Description: 构建请求参数
		 * @param request
		 * @param response
		 * @return
		 */
		public JSONObject buildBizParams(HttpServletRequest request, HttpServletResponse response,
										 String sessionId, String message);
	}
}
